<template>
  <div class="main-box">
    <el-drawer
      :visible.sync="isDrawer"
      :direction="direction"
      size="400px"
      :with-header="false"
    >
      <div class="head-box">
        <div class="identifier-box"></div>
        <div>项目信息</div>
        <div class="iconfont icon-guanbi" @click="isDrawer = false"></div>
      </div>
      <div class="info-box">
        <div class="left-box">
          <div>负责人：</div>
          <div>项目编号：</div>
          <div>项目简称：</div>
          <div>项目全称：</div>
          <div>所处阶段：</div>
          <div>所处城市：</div>
          <div>工程负责人：</div>
          <div>电气负责人：</div>
          <div>研发负责人：</div>
        </div>
        <div class="right-box">
          <div>{{ sale }}</div>
          <div>{{ proInfoRow.procode }}</div>
          <div class="proname-box">{{ proInfoRow.proname }}</div>
          <div>{{ proInfoRow.proshortname }}</div>
          <div>{{ proInfoRow.stageName }}</div>
          <div>{{ proInfoRow.proprovince + "-" + proInfoRow.procity }}</div>
          <div>{{ engineering }}</div>
          <div>{{ electrical }}</div>
          <div>{{ research }}</div>
        </div>
      </div>
    </el-drawer>
  </div>
</template>

<script>
import { getEmpolyeeListApi, getProjectTeamApi } from "@/api/index";

export default {
  props: {
    drawer: {
      type: Boolean,
      default: false,
    },
    // proInfoRow: {
    //   type: Object,
    //   default: null,
    // },
  },
  data() {
    return {
      // 是否弹出抽屉
      isDrawer: false,
      // 抽屉弹出方向
      direction: "rtl",
      // 项目名称
      proName: "",
      proInfoRow: "",
      EmpolyeeList: [],
      engineering: "",
      electrical: "",
      sale: "",
      research: "",
    };
  },

  mounted() {},

  methods: {
    openDrawer(row) {
      this.proInfoRow = row;
      console.log("drawer---->", row);
      this.proName = row.proshortname;
      this.isDrawer = true;
      let data = {
        procode: row.procode,
      };
      this.getProjectTeam(data);
    },

    //  获取人员信息
    async getProjectTeam(data) {
      this.EmpolyeeList = await getEmpolyeeListApi();
      let res = await getProjectTeamApi(data);
      console.log("ccccccccccc", res);
      this.engineering = res[0].projectmanager
        ? this.findEmpolyee(res[0].projectmanager)
        : "无";
      this.electrical = res[0].electrical
        ? this.findEmpolyee(res[0].electrical)
        : "无";
      this.sale = res[0].salescommerce
        ? this.findEmpolyee(res[0].salescommerce)
        : "无";
      this.research = res[0].devleader
        ? this.findEmpolyee(res[0].devleader)
        : "无";
    },

    findEmpolyee(code) {
      return this.EmpolyeeList.find((item) => {
        return item.empcode === code;
      }).empname;
    },
  },
};
</script>

<style lang="scss" scoped>
.main-box {
  .drawer-title {
    font-size: 16px;
  }
  .head-box {
    border-bottom: 1px solid #dddcdc;
    height: 30px;
    width: 432px;
    padding-right: 40px;
    line-height: 30px;
    text-align: start;
    font-size: 16px;
    font-weight: bold;
    margin-top: 10px;
    margin-bottom: 10px;
    padding-left: 20px;
    display: flex;
    align-items: center;

    .identifier-box {
      height: 10px;
      width: 5px;
      margin-right: 6px;
      background: #11a70c;
    }

    .icon-guanbi {
      margin-left: 73%;
    }
    .icon-guanbi:hover {
      cursor: pointer;
    }
  }

  .info-box {
    /* border: 1px solid red; */
    width: 100%;
    padding-left: 8%;
    display: flex;

    .left-box {
      width: 100px;
      text-align: end;
    }

    .right-box {
      width: 60%;

      > div {
        text-align: start;
      }
      .proname-box {
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
      }
    }

    .left-box,
    .right-box {
      /* border: 1px solid blue; */

      > div {
        /* border: 1px solid blue; */
        height: 30px;
        width: 100%;
        line-height: 30px;
        font-size: 14px;
        margin: 5px 0;

        > input {
          padding-left: 15px;
          width: 92%;
          height: 20px;
          border: 1px solid #c8ccce;
          border-radius: 4px;
        }

        .el-select {
          width: 100%;
        }

        .el-cascader {
          width: 100%;
        }
      }

      .work-detail {
        max-height: 90px;
        line-height: 20px;
      }
    }
  }
}
</style>